package com.sushi.config;

import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;

import javax.sql.DataSource;

@PropertySource("classpath:jdbc.properties")
public class MybatisConfig {
    @Bean
    public SqlSessionFactoryBean SqlSessionFactory(DataSource ds) {
        SqlSessionFactoryBean sf = new SqlSessionFactoryBean();
        sf.setTypeAliasesPackage("com.sushi.pojo");
        sf.setDataSource(ds);
        return sf;
    }
    @Bean
//    public MapperScannerConfigurer getMapperScannerConfigurer() {
    public MapperScannerConfigurer mapperScannerConfigurer() {
        MapperScannerConfigurer map = new MapperScannerConfigurer();
        map.setBasePackage("com.sushi.dao");
        return map;
    }
}
